< Summary

Class:GDX.SimpleListExtensions
Assembly:GDX
File(s):D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/SimpleListExtensions.cs
Covered lines:157
Uncovered lines:62
Coverable lines:219
Total lines:543
Line coverage:71.6% (157 of 219)
Covered branches:0
Total branches:0
Covered methods:15
Total methods:21
Method coverage:71.4% (15 of 21)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AddUncheckedUniqueItem[T](...)0%220100%
AddUncheckedUniqueReference[T](...)0%220100%
AddWithExpandCheckUniqueItem[T](...)0%220100%
AddWithExpandCheckUniqueValue[T](...)0%330100%
AddWithExpandCheckUniqueReference[T](...)0%220100%
Contains[T](...)0%12300%
ContainsItem[T](...)0%330100%
ContainsValue[T](...)0%33092.31%
ContainsReference[T](...)0%330100%
FirstIndexOf[T](...)0%3.013091.67%
FirstIndexOfItem[T](...)0%12300%
FirstIndexOfValue[T](...)0%12300%
LastIndexOf[T](...)0%12300%
LastIndexOfItem[T](...)0%12300%
LastIndexOfValue[T](...)0%12300%
RemoveFirstItem[T](...)0%33092.86%
RemoveFirstReference[T](...)0%33092.86%
RemoveItems[T](...)0%330100%
RemoveReferences[T](...)0%330100%
RemoveLastItem[T](...)0%33092.86%
RemoveLastReference[T](...)0%33092.86%

File(s)

D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/SimpleListExtensions.cs

#LineLine coverage
 1// Copyright (c) 2020-2023 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System;
 6using System.Runtime.CompilerServices;
 7using GDX.Collections.Generic;
 8
 9namespace GDX
 10{
 11    /// <summary>
 12    ///     <see cref="GDX.Collections.Generic.SimpleList{T}" /> Based Extension Methods
 13    /// </summary>
 14    /// <remarks>
 15    ///     Methods found in this extensions class are less performant then the included methods in
 16    ///     <see cref="GDX.Collections.Generic.SimpleList{T}" />. They are seperated out to clearly delineate this
 17    ///     performance regression.
 18    /// </remarks>
 19    public static class SimpleListExtensions
 20    {
 21        /// <summary>
 22        ///     Add an item to the <see cref="SimpleList{T}" /> without checking the internal size,
 23        ///     making sure that the item is not already contained in the <see cref="SimpleList{T}" />.
 24        /// </summary>
 25        /// <param name="targetSimpleList">The target <see cref="SimpleList{T}" /> to add to.</param>
 26        /// <param name="targetItem">The target class object to add.</param>
 27        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 28        /// <returns>true/false if the operation was able to add the item successfully.</returns>
 29        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 30        public static bool AddUncheckedUniqueItem<T>(ref this SimpleList<T> targetSimpleList, T targetItem)
 31            where T : class
 932        {
 933            if (targetSimpleList.ContainsItem(targetItem))
 134            {
 135                return false;
 36            }
 37
 838            targetSimpleList.AddUnchecked(targetItem);
 739            return true;
 840        }
 41
 42        /// <summary>
 43        ///     Add an object reference to the <see cref="SimpleList{T}" /> without checking the internal size,
 44        ///     making sure that the reference is not already contained in the <see cref="SimpleList{T}" />.
 45        ///     Does not prevent addition of different objects for which Equals returns true.
 46        /// </summary>
 47        /// <param name="targetSimpleList">The target <see cref="SimpleList{T}" /> to add to.</param>
 48        /// <param name="targetReference">The target class object to add.</param>
 49        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 50        /// <returns>true/false if the operation was able to add the reference successfully.</returns>
 51        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 52        public static bool AddUncheckedUniqueReference<T>(ref this SimpleList<T> targetSimpleList, T targetReference)
 53            where T : class
 954        {
 955            if (targetSimpleList.ContainsReference(targetReference))
 156            {
 157                return false;
 58            }
 59
 860            targetSimpleList.AddUnchecked(targetReference);
 761            return true;
 862        }
 63
 64        /// <summary>
 65        ///     Add an item to the <see cref="SimpleList{T}" /> with checking the internal size (expanding as necessary)
 66        ///     making sure that the item is not already contained in the <see cref="SimpleList{T}" />.
 67        /// </summary>
 68        /// <param name="targetSimpleList">The target <see cref="SimpleList{T}" /> to add to.</param>
 69        /// <param name="targetItem">The target class object to add.</param>
 70        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 71        /// <returns>true/false if the operation was able to add the item successfully.</returns>
 72        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 73        public static bool AddWithExpandCheckUniqueItem<T>(ref this SimpleList<T> targetSimpleList, T targetItem)
 74            where T : class
 875        {
 876            if (targetSimpleList.ContainsItem(targetItem))
 177            {
 178                return false;
 79            }
 80
 781            targetSimpleList.AddWithExpandCheck(targetItem);
 782            return true;
 883        }
 84
 85        /// <summary>
 86        ///     Add an item to the <see cref="SimpleList{T}" /> with checking the internal size (expanding as necessary)
 87        ///     making sure that the item is not already contained in the <see cref="SimpleList{T}" />.
 88        /// </summary>
 89        /// <param name="targetSimpleList">The target <see cref="SimpleList{T}" /> to add to.</param>
 90        /// <param name="targetItem">The target class object to add.</param>
 91        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 92        /// <returns>true/false if the operation was able to add the item successfully.</returns>
 93        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 94        public static bool AddWithExpandCheckUniqueValue<T>(ref this SimpleList<T> targetSimpleList, T targetItem)
 95            where T : IEquatable<T>
 896        {
 897            int count = targetSimpleList.Count;
 3498            for (int i = 0; i < count; i++)
 1099            {
 10100                if (targetSimpleList.Array[i].Equals(targetItem))
 1101                {
 1102                    return false;
 103                }
 9104            }
 105
 7106            targetSimpleList.AddWithExpandCheck(targetItem);
 7107            return true;
 8108        }
 109
 110        /// <summary>
 111        ///     Add an object reference to the <see cref="SimpleList{T}" /> with checking the internal size (expanding a
 112        ///     making sure that the reference is not already contained in the <see cref="SimpleList{T}" />.
 113        ///     Does not prevent addition of different objects for which Equals returns true.
 114        /// </summary>
 115        /// <param name="targetSimpleList">The target <see cref="SimpleList{T}" /> to add to.</param>
 116        /// <param name="targetReference">The target class object to add.</param>
 117        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 118        /// <returns>true/false if the operation was able to add the reference successfully.</returns>
 119        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 120        public static bool AddWithExpandCheckUniqueReference<T>(ref this SimpleList<T> targetSimpleList, T targetReferen
 121            where T : class
 8122        {
 8123            if (targetSimpleList.ContainsReference(targetReference))
 1124            {
 1125                return false;
 126            }
 127
 7128            targetSimpleList.AddWithExpandCheck(targetReference);
 7129            return true;
 8130        }
 131
 132        /// <summary>
 133        ///     <para>Does <paramref name="targetSimpleList" /> contain <paramref name="targetItem" />?</para>
 134        /// </summary>
 135        /// <param name="targetSimpleList">The <see cref="SimpleList{T}" /> to look in.</param>
 136        /// <param name="targetItem">The target class object to look for.</param>
 137        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 138        /// <returns>true/false</returns>
 139        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 140        public static bool Contains<T>(ref this SimpleList<T> targetSimpleList, T targetItem) where T : IEquatable<T>
 0141        {
 0142            int length = targetSimpleList.Count;
 0143            T[] array = targetSimpleList.Array;
 144
 0145            for (int i = 0; i < length; i++)
 0146            {
 0147                if (array[i].Equals(targetItem))
 0148                {
 0149                    return true;
 150                }
 0151            }
 152
 0153            return false;
 0154        }
 155
 156        /// <summary>
 157        ///     <para>Does <paramref name="targetSimpleList" /> contain <paramref name="targetItem" />?</para>
 158        /// </summary>
 159        /// <remarks>Avoids using <see cref="System.Collections.Generic.EqualityComparer{T}" />.</remarks>
 160        /// <param name="targetSimpleList">The <see cref="SimpleList{T}" /> to look in.</param>
 161        /// <param name="targetItem">The target class object to look for.</param>
 162        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 163        /// <returns>true/false</returns>
 164        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 165        public static bool ContainsItem<T>(ref this SimpleList<T> targetSimpleList, T targetItem) where T : class
 22166        {
 22167            int length = targetSimpleList.Count;
 22168            T[] array = targetSimpleList.Array;
 169
 96170            for (int i = 0; i < length; i++)
 32171            {
 32172                if (array[i] == targetItem)
 6173                {
 6174                    return true;
 175                }
 26176            }
 177
 16178            return false;
 22179        }
 180
 181        /// <summary>
 182        ///     <para>Does <paramref name="targetSimpleList" /> contain <paramref name="targetItem" />?</para>
 183        /// </summary>
 184        /// <remarks>Avoids using <see cref="System.Collections.Generic.EqualityComparer{T}" />.</remarks>
 185        /// <param name="targetSimpleList">The <see cref="SimpleList{T}" /> to look in.</param>
 186        /// <param name="targetItem">The target class object to look for.</param>
 187        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 188        /// <returns>true/false</returns>
 189        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 190        public static bool ContainsValue<T>(ref this SimpleList<T> targetSimpleList, T targetItem) where T : IEquatable<
 2191        {
 2192            int length = targetSimpleList.Count;
 2193            T[] array = targetSimpleList.Array;
 194
 12195            for (int i = 0; i < length; i++)
 5196            {
 5197                if (array[i].Equals(targetItem))
 1198                {
 1199                    return true;
 200                }
 4201            }
 202
 1203            return false;
 2204        }
 205
 206        /// <summary>
 207        ///     <para>Does <paramref name="targetSimpleList" /> contain <paramref name="targetItem" />?</para>
 208        /// </summary>
 209        /// <remarks>Ignores equality check and end up comparing object pointers.</remarks>
 210        /// <param name="targetSimpleList">The <see cref="SimpleList{T}" /> to look in.</param>
 211        /// <param name="targetItem">The target class object to look for.</param>
 212        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 213        /// <returns>true/false</returns>
 214        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 215        public static bool ContainsReference<T>(ref this SimpleList<T> targetSimpleList, T targetItem) where T : class
 22216        {
 22217            int length = targetSimpleList.Count;
 22218            T[] array = targetSimpleList.Array;
 219
 96220            for (int i = 0; i < length; i++)
 32221            {
 222#pragma warning disable
 223                // ReSharper disable All
 32224                if ((System.Object)array[i] == (System.Object)targetItem)
 6225                {
 6226                    return true;
 227                }
 228                // ReSharper restore All
 229#pragma warning restore
 26230            }
 231
 16232            return false;
 22233        }
 234
 235        /// <summary>
 236        ///     Find the first index of <paramref name="targetItem" /> in <paramref name="targetSimpleList" />.
 237        /// </summary>
 238        /// <remarks>This will work for <see cref="string"/> comparisons.</remarks>
 239        /// <param name="targetSimpleList">The <see cref="SimpleList{T}" /> to look in.</param>
 240        /// <param name="targetItem">The object to be found.</param>
 241        /// <typeparam name="T">The type of the array.</typeparam>
 242        /// <returns>The index of <paramref name="targetItem" /> in <paramref name="targetSimpleList" /> backing array, 
 243        public static int FirstIndexOf<T>(ref this SimpleList<T> targetSimpleList, T targetItem) where T : IEquatable<T>
 56244        {
 56245            int length = targetSimpleList.Count;
 168246            for (int i = 0; i < length; i++)
 84247            {
 84248                if (targetSimpleList.Array[i].Equals(targetItem))
 56249                {
 56250                    return i;
 251                }
 28252            }
 0253            return -1;
 56254        }
 255
 256        /// <summary>
 257        ///     Find the first index of <paramref name="targetItem" /> in <paramref name="targetSimpleList" />.
 258        /// </summary>
 259        /// <remarks>Ignores equality check and end up comparing object pointers. Do NOT use this for <see cref="string"
 260        /// <param name="targetSimpleList">The <see cref="SimpleList{T}" /> to look in.</param>
 261        /// <param name="targetItem">The object to be found.</param>
 262        /// <typeparam name="T">The type of the array.</typeparam>
 263        /// <returns>The index of <paramref name="targetItem" /> in <paramref name="targetSimpleList" /> backing array, 
 264        public static int FirstIndexOfItem<T>(ref this SimpleList<T> targetSimpleList, T targetItem) where T : class
 0265        {
 0266            int length = targetSimpleList.Count;
 0267            for (int i = 0; i < length; i++)
 0268            {
 0269                if (targetSimpleList.Array[i] == targetItem)
 0270                {
 0271                    return i;
 272                }
 0273            }
 0274            return -1;
 0275        }
 276
 277        /// <summary>
 278        ///     Find the first index of <paramref name="targetValue" /> in <paramref name="targetSimpleList" />.
 279        /// </summary>
 280        /// <param name="targetSimpleList">The <see cref="SimpleList{T}" /> to look in.</param>
 281        /// <param name="targetValue">The value to be found.</param>
 282        /// <typeparam name="T">The type of the array.</typeparam>
 283        /// <returns>The index of <paramref name="targetValue" /> in <paramref name="targetSimpleList" /> backing array,
 284        public static int FirstIndexOfValue<T>(ref this SimpleList<T> targetSimpleList, T targetValue) where T : struct
 0285        {
 0286            int length = targetSimpleList.Count;
 0287            for (int i = 0; i < length; i++)
 0288            {
 0289                if (targetSimpleList.Array[i].Equals(targetValue))
 0290                {
 0291                    return i;
 292                }
 0293            }
 294
 0295            return -1;
 0296        }
 297
 298
 299        /// <summary>
 300        ///     Find the last index of <paramref name="targetItem" /> in <paramref name="targetSimpleList" />.
 301        /// </summary>
 302        /// <remarks>This will work for <see cref="string"/> comparisons.</remarks>
 303        /// <param name="targetSimpleList">The <see cref="SimpleList{T}" /> to look in.</param>
 304        /// <param name="targetItem">The object to be found.</param>
 305        /// <typeparam name="T">The type of the array.</typeparam>
 306        /// <returns>The index of <paramref name="targetItem" /> in <paramref name="targetSimpleList" /> backing array, 
 307        public static int LastIndexOf<T>(ref this SimpleList<T> targetSimpleList, T targetItem) where T : IEquatable<T>
 0308        {
 0309            int length = targetSimpleList.Count;
 0310            for (int i = length - 1; i >= 0; i--)
 0311            {
 0312                if (targetSimpleList.Array[i].Equals(targetItem))
 0313                {
 0314                    return i;
 315                }
 0316            }
 317
 0318            return -1;
 0319        }
 320
 321        /// <summary>
 322        ///     Find the last index of <paramref name="targetItem" /> in <paramref name="targetSimpleList" />.
 323        /// </summary>
 324        /// <param name="targetSimpleList">The <see cref="SimpleList{T}" /> to look in.</param>
 325        /// <param name="targetItem">The object to be found.</param>
 326        /// <typeparam name="T">The type of the array.</typeparam>
 327        /// <returns>The index of <paramref name="targetItem" /> in <paramref name="targetSimpleList" /> backing array, 
 328        public static int LastIndexOfItem<T>(ref this SimpleList<T> targetSimpleList, T targetItem) where T : class
 0329        {
 0330            int length = targetSimpleList.Count;
 0331            for (int i = length - 1; i >= 0; i--)
 0332            {
 0333                if (targetSimpleList.Array[i] == targetItem)
 0334                {
 0335                    return i;
 336                }
 0337            }
 338
 0339            return -1;
 0340        }
 341
 342        /// <summary>
 343        ///     Find the last index of <paramref name="targetValue" /> in <paramref name="targetSimpleList" />.
 344        /// </summary>
 345        /// <param name="targetSimpleList">The <see cref="SimpleList{T}" /> to look in.</param>
 346        /// <param name="targetValue">The value to be found.</param>
 347        /// <typeparam name="T">The type of the array.</typeparam>
 348        /// <returns>The index of <paramref name="targetValue" /> in <paramref name="targetSimpleList" /> backing array,
 349        public static int LastIndexOfValue<T>(ref this SimpleList<T> targetSimpleList, T targetValue) where T : struct
 0350        {
 0351            int length = targetSimpleList.Count;
 0352            for (int i = length - 1; i >= 0; i--)
 0353            {
 0354                if (targetSimpleList.Array[i].Equals(targetValue))
 0355                {
 0356                    return i;
 357                }
 0358            }
 359
 0360            return -1;
 0361        }
 362
 363        /// <summary>
 364        ///     <para>Removes the first <paramref name="targetItem" /> from the provided <paramref name="targetSimpleLis
 365        /// </summary>
 366        /// <remarks>Avoids using <see cref="System.Collections.Generic.EqualityComparer{T}" />.</remarks>
 367        /// <param name="targetSimpleList">The target <see cref="SimpleList{T}" />.</param>
 368        /// <param name="targetItem">The target object to remove from the <paramref name="targetSimpleList" />.</param>
 369        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 370        /// <returns>true/false if an item was removed.</returns>
 371        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 372        public static bool RemoveFirstItem<T>(ref this SimpleList<T> targetSimpleList, T targetItem) where T : class
 2373        {
 2374            int length = targetSimpleList.Count;
 2375            T[] array = targetSimpleList.Array;
 376
 18377            for (int i = 0; i < length; i++)
 8378            {
 379                // Skip to next if its not what we are looking for
 8380                if (array[i] != targetItem)
 7381                {
 7382                    continue;
 383                }
 384
 1385                targetSimpleList.RemoveAt(i);
 1386                return true;
 387            }
 388
 1389            return false;
 2390        }
 391
 392        /// <summary>
 393        ///     <para>Removes the first <paramref name="targetReference" /> from the provided <paramref name="targetSimp
 394        ///     Only removes direct object references, i.e. equivalent strings at different memory addresses would not b
 395        /// </summary>
 396        /// <remarks>Avoids using <see cref="System.Collections.Generic.EqualityComparer{T}" />.</remarks>
 397        /// <param name="targetSimpleList">The target <see cref="SimpleList{T}" />.</param>
 398        /// <param name="targetReference">The target object to remove from the <paramref name="targetSimpleList" />.</pa
 399        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 400        /// <returns>true/false if an object reference was removed.</returns>
 401        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 402        public static bool RemoveFirstReference<T>(ref this SimpleList<T> targetSimpleList, T targetReference) where T :
 2403        {
 2404            int length = targetSimpleList.Count;
 2405            T[] array = targetSimpleList.Array;
 406
 18407            for (int i = 0; i < length; i++)
 8408            {
 409#pragma warning disable
 410                // ReSharper disable All
 8411                if ((System.Object)array[i] == (System.Object)targetReference)
 1412                {
 1413                    targetSimpleList.RemoveAt(i);
 1414                    return true;
 415                }
 416                // ReSharper restore All
 417#pragma warning restore
 7418            }
 419
 1420            return false;
 2421        }
 422
 423        /// <summary>
 424        ///     <para>Removes all <paramref name="targetItem" /> from the provided <paramref name="targetSimpleList" />.
 425        /// </summary>
 426        /// <remarks>Avoids using <see cref="System.Collections.Generic.EqualityComparer{T}" />.</remarks>
 427
 428        /// <param name="targetSimpleList">The target <see cref="SimpleList{T}" />.</param>
 429        /// <param name="targetItem">The item to remove from the <paramref name="targetSimpleList" />.</param>
 430        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 431        /// <returns>true/false if items were removed.</returns>
 432        public static bool RemoveItems<T>(ref this SimpleList<T> targetSimpleList, T targetItem) where T : class
 1433        {
 1434            int length = targetSimpleList.Count;
 1435            T[] array = targetSimpleList.Array;
 1436            bool removedItems = false;
 437
 14438            for (int i = length - 1; i >= 0; i--)
 6439            {
 440                // Skip to next if its not what we are looking for
 6441                if (array[i] != targetItem)
 4442                {
 4443                    continue;
 444                }
 445
 2446                targetSimpleList.RemoveAt(i);
 2447                removedItems = true;
 2448            }
 449
 1450            return removedItems;
 1451        }
 452
 453        /// <summary>
 454        ///     <para>Removes all instances of references to <paramref name="targetReference" /> from the provided <para
 455        ///     Only removes direct object references, i.e. equivalent strings at different memory addresses would not b
 456        /// </summary>
 457        /// <remarks>Avoids using <see cref="System.Collections.Generic.EqualityComparer{T}" />.</remarks>
 458
 459        /// <param name="targetSimpleList">The target <see cref="SimpleList{T}" />.</param>
 460        /// <param name="targetReference">The object reference to remove from the <paramref name="targetSimpleList" />.<
 461        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 462        /// <returns>true/false if any references were removed.</returns>
 463        public static bool RemoveReferences<T>(ref this SimpleList<T> targetSimpleList, T targetReference) where T : cla
 1464        {
 1465            int length = targetSimpleList.Count;
 1466            T[] array = targetSimpleList.Array;
 1467            bool removedItems = false;
 468
 14469            for (int i = length - 1; i >= 0; i--)
 6470            {
 471#pragma warning disable
 472                // ReSharper disable All
 6473                if ((System.Object)array[i] == (System.Object)targetReference)
 2474                {
 2475                    targetSimpleList.RemoveAt(i);
 2476                    removedItems = true;
 2477                }
 478                // ReSharper restore All
 479#pragma warning restore
 6480            }
 481
 1482            return removedItems;
 1483        }
 484
 485        /// <summary>
 486        ///     <para>Removes the last <paramref name="targetItem" /> from the provided <paramref name="targetSimpleList
 487        /// </summary>
 488        /// <remarks>Avoids using <see cref="System.Collections.Generic.EqualityComparer{T}" />.</remarks>
 489        /// <param name="targetSimpleList">The target <see cref="SimpleList{T}" />.</param>
 490        /// <param name="targetItem">The target object to remove from the <paramref name="targetSimpleList" />.</param>
 491        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 492        /// <returns>true/false if an item was removed.</returns>
 493        public static bool RemoveLastItem<T>(ref this SimpleList<T> targetSimpleList, T targetItem) where T : class
 2494        {
 2495            int length = targetSimpleList.Count;
 2496            T[] array = targetSimpleList.Array;
 497
 18498            for (int i = length - 1; i >= 0; i--)
 8499            {
 500                // Skip to next if its not what we are looking for
 8501                if (array[i] != targetItem)
 7502                {
 7503                    continue;
 504                }
 505
 1506                targetSimpleList.RemoveAt(i);
 1507                return true;
 508            }
 509
 1510            return false;
 2511        }
 512
 513        /// <summary>
 514        ///     <para>Removes the last reference to <paramref name="targetReference" /> from the provided <paramref name
 515        ///     Only removes direct object references, i.e. equivalent strings at different memory addresses would not b
 516        /// </summary>
 517        /// <remarks>Avoids using <see cref="System.Collections.Generic.EqualityComparer{T}" />.</remarks>
 518        /// <param name="targetSimpleList">The target <see cref="SimpleList{T}" />.</param>
 519        /// <param name="targetReference">The target object reference to remove from the <paramref name="targetSimpleLis
 520        /// <typeparam name="T">The type of the <see cref="SimpleList{T}" />.</typeparam>
 521        /// <returns>true/false if an object reference was removed.</returns>
 522        public static bool RemoveLastReference<T>(ref this SimpleList<T> targetSimpleList, T targetReference) where T : 
 2523        {
 2524            int length = targetSimpleList.Count;
 2525            T[] array = targetSimpleList.Array;
 526
 18527            for (int i = length - 1; i >= 0; i--)
 8528            {
 529#pragma warning disable
 530                // ReSharper disable All
 8531                if ((System.Object)array[i] == (System.Object)targetReference)
 1532                {
 1533                    targetSimpleList.RemoveAt(i);
 1534                    return true;
 535                }
 536                // ReSharper restore All
 537#pragma warning restore
 7538            }
 539
 1540            return false;
 2541        }
 542    }
 543}

Coverage by test methods










































































































































































































































































































































































































































































































































































































































































































Methods/Properties

AddUncheckedUniqueItem[T](, T)
AddUncheckedUniqueReference[T](, T)
AddWithExpandCheckUniqueItem[T](, T)
AddWithExpandCheckUniqueValue[T](, T)
AddWithExpandCheckUniqueReference[T](, T)
Contains[T](, T)
ContainsItem[T](, T)
ContainsValue[T](, T)
ContainsReference[T](, T)
FirstIndexOf[T](, T)
FirstIndexOfItem[T](, T)
FirstIndexOfValue[T](, T)
LastIndexOf[T](, T)
LastIndexOfItem[T](, T)
LastIndexOfValue[T](, T)
RemoveFirstItem[T](, T)
RemoveFirstReference[T](, T)
RemoveItems[T](, T)
RemoveReferences[T](, T)
RemoveLastItem[T](, T)
RemoveLastReference[T](, T)